package com.kuyun.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kuyun.entity.User1;
import com.kuyun.entity.UserComment;
import com.kuyun.mapper.LoginMapper;
import com.kuyun.service.LoginService;

@Service
public class LoginServiceImpl implements LoginService {

	@Autowired
	private LoginMapper loginMapper;

	@Override
	public User1 getUser1(String userId, String password) {
		try {
			return loginMapper.getUser1(userId, password);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public int doRegister(String userId, String userName, String password, int userAge, String userSex) {
		try {
			return loginMapper.doRegister(userId, userName, password, userAge, userSex);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}

	@Override
	public String getUserName(String userId) {
		return loginMapper.getUserName(userId);
	}

	@Override
	public int doCommentSave(String userId, String userName, String comment, Date curDate) {
		try {
			return loginMapper.doCommentSave(userId, userName, comment, curDate);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}

	@Override
	public List<UserComment> getCommentList(String userId) {
		List<UserComment> userComment = null;
		userComment = loginMapper.getCommentList(userId);
		if (userComment != null) {
			return userComment;
		}
		return null;
	}

	@Override
	public int delectComment(String comment) {
		return loginMapper.delectComment(comment);
	}

}
